(function(){"use strict";BX.namespace("BX.Landing.UI.Card");var e=BX.Landing.Utils.addClass;var i=BX.Landing.Utils.append;var a=BX.Landing.Utils.create;BX.Landing.UI.Card.BlockPreviewCard=function(t){BX.Landing.UI.Card.BaseCard.apply(this,arguments);this.layout.classList.add("landing-ui-card-block-preview");this.mode=typeof t.mode==="string"?t.mode:"img";this.title=typeof t.title==="string"?t.title:"";this.appExpired=typeof t.app_expired==="boolean"?t.app_expired:false;this.repoId=t.repo_id||null;this.imageSrc=typeof t.image==="string"?t.image:"/bitrix/images/landing/empty-preview.png";this.code=typeof t.code==="string"?t.code:"";this.favorite=t.favorite;this.favoriteMy=t.favoriteMy;this.isNew=typeof t.isNew==="boolean"?t.isNew:false;this.imageContainer=BX.create("div",{props:{className:"landing-ui-card-block-preview-image-container"}});this.body.appendChild(this.imageContainer);this.header.innerText=this.title;this.layout.dataset.code=this.code;this.requiresUpdates=t.requires_updates;if(this.isNew){this.title=BX.create("span",{props:{className:"landing-ui-new-inline"},text:BX.Landing.Loc.getMessage("LANDING_BLOCKS_LIST_PREVIEW_NEW")}).outerHTML+"&nbsp;"+this.title;this.header.innerHTML=this.title}if(this.repoId||this.favorite||this.appExpired){this.labels=BX.create("div",{props:{className:"landing-ui-card-labels"}});BX.insertAfter(this.labels,this.getHeader())}if(this.repoId||this.appExpired){var s=BX.create("div",{props:{className:"landing-ui-card-label landing-ui-card-label-repo"},text:BX.Landing.Loc.getMessage("LANDING_BLOCKS_LIST_PREVIEW_MARKET"),dataset:{hint:BX.Landing.Loc.getMessage("LANDING_BLOCKS_LIST_PREVIEW_MARKET_HINT"),hintNoIcon:"Y"}});BX.append(s,this.labels);BX.UI.Hint.init(this.labels)}if(this.favorite){if(this.favoriteMy){BX.append(BX.create("div",{props:{className:"landing-ui-card-label landing-ui-card-label-my"},text:BX.Landing.Loc.getMessage("LANDING_BLOCKS_LIST_PREVIEW_MY_NEW")}),this.labels)}BX.append(BX.create("div",{props:{className:"landing-ui-card-label landing-ui-card-label-favorite"},text:BX.Landing.Loc.getMessage("LANDING_BLOCKS_LIST_PREVIEW_FAVORITE")}),this.labels);var n=this.code.split("@").length===2?this.code.split("@")[1]:false;if(n&&this.favoriteMy){BX.Runtime.loadExtension("ui.dialogs.messagebox").then((()=>{const e=this.getRemoveButton();e.onclick=e=>{e.stopPropagation();BX.UI.Dialogs.MessageBox.show({message:BX.Landing.Loc.getMessage("LANDING_BLOCKS_LIST_PREVIEW_DELETE_MSG"),buttons:BX.UI.Dialogs.MessageBoxButtons.YES_CANCEL,onYes:()=>BX.Landing.Backend.getInstance().action("Landing::unFavoriteBlock",{blockId:n}).then((()=>{const e=BX.Landing.Main.getInstance();e.removeBlockFromList(this.code);return true})).catch((function(e){console.log("error",e);return false}))})};BX.append(e,this.getBody())}))}}if(this.appExpired){this.addWarning(BX.Landing.Loc.getMessage("LANDING_BLOCKS_LIST_PREVIEW_EXPIRED"));this.onClickHandler=function(){}}if(this.mode==="background"){this.imageContainer.style.backgroundImage="url("+this.imageSrc+")"}else{var r=this.imageSrc||"/bitrix/images/landing/empty-preview.png";this.image=BX.create("img",{props:{src:r},attrs:{style:"opacity: "+(this.imageSrc?1:.6)}});this.imageContainer.appendChild(this.image)}if(this.requiresUpdates){e(this.layout,"landing-ui-requires-update");var o=a("div",{props:{className:"landing-ui-requires-update-overlay"},children:[a("div",{props:{className:"landing-ui-requires-update-overlay-footer"},html:BX.Landing.Loc.getMessage("LANDING_BLOCK_REQUIRES_UPDATE_MESSAGE")})]});i(o,this.imageContainer);this.onClickHandler=function(){}}};BX.Landing.UI.Card.BlockPreviewCard.prototype={constructor:BX.Landing.UI.Card.BlockPreviewCard,__proto__:BX.Landing.UI.Card.BaseCard.prototype}})();
//# sourceMappingURL=block_preview_card.map.js